<?php
namespace app\admin\controller;

use think\Db;

class AdminLog extends Backend
{
    protected $searchFields = 'title,desc,ip';

    /**
     * 全部的操作日志
     *
     * @return void
     */
    public function index()
    {
        if ($this->request->isAjax()) {
            list($where, $sort, $order, $page, $offset, $limit) = $this->buildSearchParams($this->searchFields);
            $rows = Db::name($this->tableName)->alias('a')->join('__ADMIN__ b','a.admin_id=b.id')->where($where)->field('a.*,b.username')->order($sort, $order)->paginate([
                'list_rows' => $limit,
                'page' => $page,
            ]);
            $data = [
                'total' => $rows->total(),
                'rows' => $rows->items(),
            ];
            return json($data);
        }
        return $this->fetch();
    }
}
